package com.shenmazong.core;

/**
 * @program: server-java-demo
 * @description: 单例模式：懒汉式，线程安全
 * @author: 亮子说编程
 * @create: 2020-10-15 09:16
 **/
public class Singleton02 {
    private static Singleton02 instance;

    private Singleton02() {
    }

    // 加锁
    public static synchronized Singleton02 getInstance() {
        if (instance == null) {
            instance = new Singleton02();
        }
        return instance;
    }
}
